/**
 * @author gao
 * @date 2025/7/1 18:00
 */

public class Demo4 {

    private static int count = 0;
    private static Object lock = new Object();

void menthod1() {
    synchronized (this) {
        menthod2();
    }
}

void menthod2() {
    menthod3();
}

private void menthod3() {
    menthod4();
}

void menthod4() {

}

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            synchronized (lock) {
                synchronized (lock) {
                    for (int i = 0; i < 50_000; i++) {
                        count++;
                    }
                }
            }
        });

        Thread t2 = new Thread(() -> {
            synchronized (lock) {
                for (int i = 0; i < 50_000; i++) {
                    count++;
                }
            }
        });
    }
}